package com.mayikt.days03;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName Test041
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test041 {
    public static void main(String[] args) throws InterruptedException {
        LinkedBlockingQueue<String> strings = new LinkedBlockingQueue<>(3);
        strings.offer("mayikt");
        strings.offer("meite");
        strings.offer("wangmazi");
        boolean xiaowei = strings.offer("xiaowei", 3, TimeUnit.SECONDS);
        System.out.println(xiaowei);
//
//        System.out.println(strings.poll());
//        System.out.println(strings.poll());
//        System.out.println(strings.poll());
//        System.out.println(strings.poll(10, TimeUnit.SECONDS));
        //poll 取出成功的情况下 会改将元素从队列中删除
        //peek() 取出成功之后，不会删除该元素
    }
}
